package com.heer.gymnasium.module.reservation.beans;

import android.os.Parcel;
import android.os.Parcelable;

import com.heer.gymnasium.base.BaseBean;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.Collection;
import java.util.List;

/**
 * Created by yan
 * on 2018/1/29
 * 订场界面网格Item实体类
 */

public class ReservationGridBean extends BaseBean implements Parcelable {
    public static final String TYPE_FIELD = "place";
    public static final String TYPE_TIME = "time";
    public static final String STATUS_EMPTY = "0";
    //    public static final String STATUS_SOLD_BY_ME = "1";
    public static final String STATUS_SOLD = "1";
    public static final String STATUS_FELLOW = "3";
    public static final String STATUS_MATCH = "2";
    public static final String STATUS_MINE = "5";


    private String text;

    private String key;

    private String state;

    private String id;

    private String startTime;

    private String endTime;

    private String categoryId;


    protected ReservationGridBean(Parcel in) {
        text = in.readString();
        key = in.readString();
        state = in.readString();
        id = in.readString();
        startTime = in.readString();
        endTime = in.readString();
    }

    public ReservationGridBean() {

    }

    public static final Creator<ReservationGridBean> CREATOR = new Creator<ReservationGridBean>() {
        @Override
        public ReservationGridBean createFromParcel(Parcel in) {
            return new ReservationGridBean(in);
        }

        @Override
        public ReservationGridBean[] newArray(int size) {
            return new ReservationGridBean[size];
        }
    };

    public String getText() {
        return text;
    }

    public void setText(String text) {
        this.text = text;
    }

    public String getKey() {
        return key;
    }

    public void setKey(String key) {
        this.key = key;
    }

    public String getState() {
        return state;
    }

    public void setState(String state) {
        this.state = state;
    }

    public String getId() {
        return id;
    }

    public void setId(String id) {
        this.id = id;
    }

    public String getStartTime() {
        return startTime;
    }

    public void setStartTime(String startTime) {
        this.startTime = startTime;
    }

    public String getEndTime() {
        return endTime;
    }

    public void setEndTime(String endTime) {
        this.endTime = endTime;
    }

    public String getCategoryId() {
        return categoryId;
    }

    public void setCategoryId(String categoryId) {
        this.categoryId = categoryId;
    }

    public static Collection<? extends ReservationGridBean> dataChange(List<List<ReservationBookItemResponseBean>> data) {
        List<ReservationGridBean> newList = new ArrayList<>();
        int row = 0;
        for (List<ReservationBookItemResponseBean> list : data) {
            int column = 0;
            for (ReservationBookItemResponseBean item : list) {
                ReservationGridBean bean = new ReservationGridBean();
                bean.setText(item.getShow());
                bean.setState(item.getStatus());
                bean.setId(item.getPlace_id());
                bean.setStartTime(item.getStart_time());
                bean.setEndTime(item.getEnd_time());
                bean.setCategoryId(item.getCategory_id());
                if (row == 0) {
                    bean.setKey(TYPE_FIELD);
                }

                if (column == 0) {
                    bean.setKey(TYPE_TIME);
                }
                newList.add(bean);
                column++;
            }
            row++;
        }
        return newList;
    }

    @Override
    public int describeContents() {
        return 0;
    }

    @Override
    public void writeToParcel(Parcel parcel, int i) {
        parcel.writeString(text);
        parcel.writeString(key);
        parcel.writeString(state);
        parcel.writeString(id);
        parcel.writeString(startTime);
        parcel.writeString(endTime);
    }
}
